<?php echo $this->fetch('header.html'); ?>
<style>
    .coupon_list{background:#fff;}
    .coupon_list ul li{padding: 8px 10px 9px 10px;border-bottom: 1px solid #f5f5f5;height: 80px;}
    .coupon_list ul li .pic{width: 100px;height: 80px;margin: 0px 12px 0 0;display: inline-block;overflow: hidden;position: relative;float:left;}
    .coupon_list ul li .info{float:left;}
    .coupon_list ul li .info p{font-size: 12px;height:25px;line-height:25px;overflow: hidden;}
</style>
<script>
    function add_coupon(coupon_id) {
<?php if (! $this->_var['visitor']['user_id']): ?>
        alert(lang.login_please);
        return;
<?php endif; ?>
        var url = SITE_URL + '/index.php?app=my_coupon&act=add';
        $.getJSON(url, {'coupon_id': coupon_id}, function(data) {
            if (data.done)
            {
                alert(data.retval);
            }
            else
            {
                alert(data.msg);
            }
        });
    }
</script>
<div class="coupon_list">
    <ul class="list">
        <?php $_from = $this->_var['coupons']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'coupon');$this->_foreach['fe_coupon'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_coupon']['total'] > 0):
    foreach ($_from AS $this->_var['coupon']):
        $this->_foreach['fe_coupon']['iteration']++;
?>
        <a href="javascript:void(0)" onclick="add_coupon(<?php echo $this->_var['coupon']['coupon_id']; ?>)">
            <li>
                <div class="pic">
                    <img src="<?php echo $this->_var['site_url']; ?>/<?php echo $this->_var['coupon']['coupon_bg']; ?>" width="100" height="80" />
                </div>
                <div class="info">
                    <p><?php echo local_date("Y-m-d",$this->_var['coupon']['start_time']); ?> 至 <?php if ($this->_var['coupon']['end_time']): ?><?php echo local_date("Y-m-d",$this->_var['coupon']['end_time']); ?><?php else: ?>no_limit<?php endif; ?></p>
                    <p>满<?php echo price_format($this->_var['coupon']['min_amount']); ?></p>
                    <p>可抵扣<?php echo price_format($this->_var['coupon']['coupon_value']); ?></p>
                </div>
            </li>
        </a>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </ul>
</div>
<?php echo $this->fetch('footer.html'); ?>